/**
 * Created by Administrator on 2017/7/31.
 */
define(function(require, exports){
	// 溢价列表
	exports.onMain = function(boot,data,app){
		if (!app.routerValid('')) {
			return;
		}
		var title = LANG('特殊溢价设置');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title:"",
			type: 'tabSidebar',
			content_config: {
				'addClass': 'cool',
			}
		});
		con.createBusiness(data.name + '_a', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': 'admin'
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});
		con.createBusiness(data.name, 'admin/premium//action/add.main', {
			'contentType': 'info'
		}, function(mod, created){
			if(mod){
			}
		});
		con.createBusiness(data.name + 'channel', 'admin/premium/action/list.channel', {
			tabText: LANG('渠道'),
			tabType: 'channel',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
		con.createBusiness(data.name + 'spot', 'admin/premium/action/list.spot', {
			tabText: LANG('广告位'),
			tabType: 'spot',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
		con.createBusiness(data.name + 'order', 'admin/premium/action/list.order', {
			tabText: LANG('订单'),
			tabType: 'order',
			isBrand: true
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
	};
	exports.onEdit = function( boot, data, app ) {
		var id = +data.param;
		if(!app.routerValid('')) {
			return;
		}
		var title = id ? LANG('编辑溢价规则') : LANG('新建溢价规则');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title:title,
			type: 'sidebar'
		});
		con.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': ''
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});
		con.createBusiness(data.name, 'admin/premium/action/edit.base', {
		}, function(mod, created){
			if(created){
				mod.reset();
			}
			if(id){
				mod.load(id);
			}
		});
	};
	exports.onSaveas = function( boot, data, app ) {
		var id = +data.param;
		if(!app.routerValid('')) {
			return;
		}
		var title = LANG('新建溢价规则');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title:title,
			type: 'sidebar'
		});
		con.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': ''
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});
		con.createBusiness(data.name, 'admin/premium/action/edit.base', {
		}, function(mod, created){
			if(created){
				mod.reset();
			}
			if(id){
				mod.load(id,true);
			}
		});
	};
});